package org.loofer.user.service.impl

import org.loofer.base.ext.convert
import org.loofer.base.ext.convertBoolean
import org.loofer.user.data.protocol.UserInfo
import org.loofer.user.data.respository.UserRepository
import org.loofer.user.service.UserService
import rx.Observable
import javax.inject.Inject

/**
 *============================================================
 * 版权： Loofer 版权所有（c）2018
 *
 * 作者：Loofer
 * 版本：1.0
 * 创建日期 ：2018/7/1 9:24.
 * 描述：
 *
 * 注:如果您修改了本类请填写以下内容作为记录，如非本人操作劳烦通知，谢谢！！！
 * Modified Date Modify Content:
 *
 *==========================================================
 */
class UserServiceImpl @Inject constructor():UserService {
    @Inject
    lateinit var repository: UserRepository

    /*
        注册
     */
    override fun register(mobile: String, pwd: String, verifyCode: String): Observable<Boolean> {
        return repository.register(mobile, pwd, verifyCode).convertBoolean()
    }

    /*
        登录
     */
    override fun login(mobile: String, pwd: String, pushId: String): Observable<UserInfo> {
        return repository.login(mobile, pwd, pushId).convert()
    }

    /*
        忘记密码
     */
    override fun forgetPwd(mobile: String, verifyCode: String): Observable<Boolean> {
        return repository.forgetPwd(mobile, verifyCode).convertBoolean()
    }

    /*
        重置密码
     */
    override fun resetPwd(mobile: String, pwd: String): Observable<Boolean> {
        return repository.resetPwd(mobile, pwd).convertBoolean()
    }

    /*
        修改用户资料
     */
    override fun editUser(userIcon: String, userName: String, userGender: String, userSign: String): Observable<UserInfo> {
        return repository.editUser(userIcon,userName,userGender,userSign).convert()
    }

}